package com.admin.config;


import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitmqConfig {
    // 交换机名称  wmnesauto
    public static final String EXCHANGE_DIRECT_WMNEWSAUTO = "exchange_direct_wmnesauto";

    // 队列名称1  wemedia_ADMIN
    public static final String QUEUE_WMNESAUTO_WEMEDIA_ADMIN = "queue_wmnesauto_wemeida_admin";


    // 声明交换机
    @Bean(EXCHANGE_DIRECT_WMNEWSAUTO)
    public Exchange EXCHANGE_DIRECT_AUTHAUTO(){
        return ExchangeBuilder.directExchange(EXCHANGE_DIRECT_WMNEWSAUTO).durable(true).build();
    }
    // 声明队列
    @Bean(QUEUE_WMNESAUTO_WEMEDIA_ADMIN)
    public Queue QUEUE_AUTHAUTO_USER(){
        Queue queue = new Queue(QUEUE_WMNESAUTO_WEMEDIA_ADMIN);
        return queue;
    }


    // 绑定交换机和队列
    @Bean("bind1")
    public Binding EXCHANGE_DIRECT_AUTHAUTO_USER(@Qualifier(EXCHANGE_DIRECT_WMNEWSAUTO) Exchange exchange,
                                                 @Qualifier(QUEUE_WMNESAUTO_WEMEDIA_ADMIN) Queue queue){
        return BindingBuilder.bind(queue).to(exchange).with("wmnesauto").noargs();
    }


}
